/* -*- mode: c++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- */

#ifndef _CPP_H_
#define _CPP_H_

#include <stdio.h>
#include <string>

enum TokenType {
    tkINT = 300,
    tkFLOAT,
    tkSTRING,
    tkCHAR,
    rwTRY,
    rwCATCH,
    rwFINALLY,
    rwIF,
    rwELSE,
    rwDO,
    rwWHILE,
    rwFOR,
    rwSWITCH,
    rwCASE,
    rwDEFAULT,
    rwENUM,
    rwUNION,
    rwSTRUCT,
    rwCLASS,
    rwTEMPLATE,
    rwTYPENAME,
    rwTYPEDEF,
    rwNAMESPACE,
    rwSIZEOF,
    rwNEW,
    rwDELETE,
    rwCONTINUE,
    rwBREAK,
    rwASM,
    rwATTRIBUTE,
    rwMUTABLE,
    rwCONST_CAST,
    rwSTATIC_CAST,
    rwDYNAMIC_CAST,
    rwREINTERPRET_CAST,
    rwINLINE,
    rwRETURN,
    rwGOTO,
    rwTHROW,
    rwVOLATILE,
    rwSTATIC,
    rwEXTERN,
    rwUSING,
    rwPUBLIC,
    rwPROTECTED,
    rwPRIVATE,
    rwREGISTER,
    rwTHIS,
    rwFRIEND,
    rwEXPLICIT,
    rwTYPEID,
    rwOPERATOR,
    rwCONST,

    tkIDENT,

    tkMACRO_DEFINE,

    tkOP,
    // ::
    tkCC,
    // :
    tkCOLON,
    // ,
    tkCOMMA,
    // &
    tkREF,
    // *
    tkPTR,
    // =
    tkASS,
    // (
    tkLEFTP,
    // )
    tkRIGHTP,
    // {
    tkLEFTB,
    // }
    tkRIGHTB,
    // <
    tkLEFTA,
    // >
    tkRIGHTA,
    // [
    tkLEFTS,
    // ]
    tkRIGHTS,
    // ;
    tkTERM,
    // ~
    tkWAVE,
    // .
    tkDOT,
};

struct TokenDesc {
    std::string text;

    int         lineno;

    int         token;

    TokenDesc(int tk, const char *tx, int l)
        : text(tx), lineno(l), token(tk)
    {
    }

    TokenDesc() : lineno(0), token(0)
    {
    }
};

extern int lex_get_token(std::string& text, int *lineno);

extern void lex_unput_token(int token, const char *text, int lineno);

extern FILE *lex_set_file(const char *fn);

extern void lex_reset_buffer(const char *sb, int size);

#endif /* _CPP_H_ */
